// -*- Mode: C++ -*-
#ifndef EVENT_H
#define EVENT_H

#include <boost/signals2.hpp>
#include <string>

class Event {
public:
     enum Type {
	  Note,
	  ControlChange
     };
     static const int NoNote = -1;
     static const int NoteOff = -2;
     static const int NoInst = -1;
     static const int NoAmp = -1;
     static const int NoEffect = -1;
     static const int NoEffectArg = -1;
     static const int strlen = 10;

     // onChange signal template
     typedef boost::signals2::signal<void (int)> OnChange;

     Event(Type type=Note, int number=NoNote, int instNum=NoInst, 
	   int val=NoAmp, int effect=NoEffect, int effectArg=NoEffectArg, 
	   int index=-1);
     ~Event();
     Type type();
     void setType(Type type);     
     void toggleType();
     int number();
     void setNumber(int number);
     int instNum();
     void setInstNum(int instNum);
     int val();
     void setVal(int val);
     int effect();
     void setEffect(int effect);
     int effectArg();
     void setEffectArg(int effectArg);
     int index();
     void setIndex(int num);
     void setEvent(int num, int inst, int val);
     void clear();

     // values as strings for display
     std::string numStr();
     std::string instNumStr();
     std::string valStr();
     std::string effectStr();
     std::string toString();
     void fromString(const std::string &str);

     // connect to onChange signal
     boost::signals2::connection onChange(const OnChange::slot_type &callback);

private:
     Type m_type;
     int m_number;
     int m_instNum;
     int m_val;
     int m_effect;
     int m_effectArg;
     // signal to emit when the event's data changes
     OnChange m_onChange;
     // index in pattern
     int m_index;

     std::string noteStr();
     std::string ccNumStr();
     void setNumFromString(std::string str);
     void setCcNumFromString(std::string str);
     void setNoteNumFromString(std::string str);
     void setInstFromString(std::string str);
     void setValFromString(std::string str);
     void setEffectFromString(std::string str);
};

#endif
